/**
 * <copyright>
 * </copyright>
 *

 */
package net.maylander.bfcpublog.bfwb.brainfuckLanguage.impl;

import java.util.Collection;

import net.maylander.bfcpublog.bfwb.brainfuckLanguage.AbstractMacroDef;
import net.maylander.bfcpublog.bfwb.brainfuckLanguage.AbstractStmt;
import net.maylander.bfcpublog.bfwb.brainfuckLanguage.BrainfuckLanguagePackage;
import net.maylander.bfcpublog.bfwb.brainfuckLanguage.BrainfuckProgram;
import net.maylander.bfcpublog.bfwb.brainfuckLanguage.SymbolDef;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Brainfuck Program</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link net.maylander.bfcpublog.bfwb.brainfuckLanguage.impl.BrainfuckProgramImpl#getName <em>Name</em>}</li>
 *   <li>{@link net.maylander.bfcpublog.bfwb.brainfuckLanguage.impl.BrainfuckProgramImpl#getSymbols <em>Symbols</em>}</li>
 *   <li>{@link net.maylander.bfcpublog.bfwb.brainfuckLanguage.impl.BrainfuckProgramImpl#getMacros <em>Macros</em>}</li>
 *   <li>{@link net.maylander.bfcpublog.bfwb.brainfuckLanguage.impl.BrainfuckProgramImpl#getStmts <em>Stmts</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class BrainfuckProgramImpl extends MinimalEObjectImpl.Container implements BrainfuckProgram
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getSymbols() <em>Symbols</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSymbols()
   * @generated
   * @ordered
   */
  protected EList<SymbolDef> symbols;

  /**
   * The cached value of the '{@link #getMacros() <em>Macros</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMacros()
   * @generated
   * @ordered
   */
  protected EList<AbstractMacroDef> macros;

  /**
   * The cached value of the '{@link #getStmts() <em>Stmts</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getStmts()
   * @generated
   * @ordered
   */
  protected EList<AbstractStmt> stmts;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected BrainfuckProgramImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return BrainfuckLanguagePackage.Literals.BRAINFUCK_PROGRAM;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<SymbolDef> getSymbols()
  {
    if (symbols == null)
    {
      symbols = new EObjectContainmentEList<SymbolDef>(SymbolDef.class, this, BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__SYMBOLS);
    }
    return symbols;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<AbstractMacroDef> getMacros()
  {
    if (macros == null)
    {
      macros = new EObjectContainmentEList<AbstractMacroDef>(AbstractMacroDef.class, this, BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__MACROS);
    }
    return macros;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<AbstractStmt> getStmts()
  {
    if (stmts == null)
    {
      stmts = new EObjectContainmentEList<AbstractStmt>(AbstractStmt.class, this, BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__STMTS);
    }
    return stmts;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__SYMBOLS:
        return ((InternalEList<?>)getSymbols()).basicRemove(otherEnd, msgs);
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__MACROS:
        return ((InternalEList<?>)getMacros()).basicRemove(otherEnd, msgs);
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__STMTS:
        return ((InternalEList<?>)getStmts()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__NAME:
        return getName();
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__SYMBOLS:
        return getSymbols();
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__MACROS:
        return getMacros();
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__STMTS:
        return getStmts();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__NAME:
        setName((String)newValue);
        return;
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__SYMBOLS:
        getSymbols().clear();
        getSymbols().addAll((Collection<? extends SymbolDef>)newValue);
        return;
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__MACROS:
        getMacros().clear();
        getMacros().addAll((Collection<? extends AbstractMacroDef>)newValue);
        return;
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__STMTS:
        getStmts().clear();
        getStmts().addAll((Collection<? extends AbstractStmt>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__NAME:
        setName(NAME_EDEFAULT);
        return;
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__SYMBOLS:
        getSymbols().clear();
        return;
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__MACROS:
        getMacros().clear();
        return;
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__STMTS:
        getStmts().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__SYMBOLS:
        return symbols != null && !symbols.isEmpty();
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__MACROS:
        return macros != null && !macros.isEmpty();
      case BrainfuckLanguagePackage.BRAINFUCK_PROGRAM__STMTS:
        return stmts != null && !stmts.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(')');
    return result.toString();
  }

} //BrainfuckProgramImpl
